package com.cu.simpleerp.system.controller;

import com.cu.simpleerp.common.ResultModel;
import com.cu.simpleerp.system.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Administrator
 * @date 2018-10-24 23:08
 */
@Controller
public class LoginController {

    private Logger log = LoggerFactory.getLogger(LoginController.class);

    @Autowired
    private UserService userService;

    @ResponseBody
    @RequestMapping("login")
    public ResultModel login(String userName, String password, HttpServletResponse response,HttpServletRequest request) {
        log.info("login userName :" + userName + " ,password :" + password);
        if(StringUtils.isBlank(userName) || StringUtils.isBlank(password)){
            return new ResultModel("error","参数或者密码为空");
        }
        ResultModel loginResult = userService.checkLogin(userName,password,response,request);
        return loginResult;
    }
}
